package com.ejianlong.tongchuang.myhiltdemo.bean

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import javax.inject.Inject
import javax.inject.Qualifier

interface Engine {

    fun start()

    fun shutDown()
}


class GasEngine @Inject constructor() : Engine{

    override fun start() {
        println("GasEngine start")
    }

    override fun shutDown() {
        println("GagEngine shutDown")
    }

}


class ElectricEngine @Inject constructor() : Engine{

    override fun start() {
        println("ElectricEngine start")
    }

    override fun shutDown() {
        println("ElectricEngine shutDown")
    }

}


@Module
@InstallIn(ActivityComponent::class)
abstract class EngineModule{

    @BindGasEngine
    @Binds
    abstract fun bindGasEngine(gasEngine: GasEngine): Engine

    @BindElectricEngine
    @Binds
    abstract fun bindElectricEngine(electricEngine: ElectricEngine) : Engine

}

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class BindGasEngine

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class BindElectricEngine
